//
//  NSString+Extension.m
//  微博2期
//
//  Created by J on 15/12/5.
//
//

#import "NSString+Extension.h"

@implementation NSString (Extension)
- (CGSize)sizeWithfont:(UIFont*)font maxW:(CGFloat)maxW{
    
    NSMutableDictionary * atts = [NSMutableDictionary dictionary];
    atts[NSFontAttributeName] = font;
    CGSize maxSize = CGSizeMake(maxW, MAXFLOAT);
    
    if (iOS7) {//获得系统版本
//        NSLog(@"%@",version);
        return [self boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:atts context:nil].size;

    }else{
        
      return   [self sizeWithFont:font constrainedToSize:maxSize];

    }
    
}

- (CGSize)sizeWithfont:(UIFont*)font{
    
    return [self sizeWithfont:font maxW:MAXFLOAT];
    
}


@end
